<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <script src="/js/jquery-3.4.1.js"></script>
    <script src="/lib/layui/layui.js"></script>
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <script charset="utf-8" src="/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
    <script>
        KindEditor.ready(function(K) {
            window.editor = K.create('#content',
                {
                    cssPath: '/kindeditor/plugins/code/prettify.css',
                    uploadJson: '/uploads',
                    allowFileManager: false
                });

        });
    </script>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">分享观影</div>
    <div class="panel-body">
        <form action="/admin/banner/save" method="post">
            <input type="hidden" id="url" value="" name="url">
            <div class="form-group">
                <label>标题：</label>
                <input type="button" id="upload" class="form-control" value="图片">
            </div>
            <div class="form-group">
                <label>开始日期：</label>
                <input type="text" id="dtstart" readonly class="form-control" name="dtstart" >
            </div>
            <div class="form-group">
                <label>结束日期：</label>
                <input type="text" id="dtend" readonly class="form-control" name="dtend" >
            </div>

            <input type="submit" class="btn btn-default" value="保存">
        </form>
    </div>
</div>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#upload' //绑定元素
            ,url: '/upload/' //上传接口
            ,accept:"images"
            ,done: function(res){
                //上传完毕回调
                if(res.error == 0){
                    $("#url").val(res.url)
                } else {
                    alert(res.message)
                }
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });


    layui.use("laydate", function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#dtstart', //指定元素
            type:"datetime",
            change: function (value, date, endDate) {
                if(value < new Date().getDate()){
                    alert("开始时间不能晚于当前时间\n")
                }
            }
        });
        laydate.render({
            elem: '#dtend', //指定元素
            type:"datetime",
            change: function(value, date, endDate){
                if(value < $("#dtstart").val()){
                    alert("开始时间不能大于结束时间\n")
                }
            }
        });
    })
</script>
</body>
</html>